import { GSprite } from "../../../../com/mui/controls/GSprite";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { UICompomentPool } from "../../../../com/mui/utils/UICompomentPool";
import { RepairAllEquipButton } from "../common/button/RepairAllEquipButton";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { Cache } from "../../cache/Cache";
import { ShopOperType } from "../shop/ShopOperType";
import { VIPUtil } from "../vip/VIPUtil";
import { LayerManager } from "../../manager/LayerManager";
import { GameController } from "../../mvc/GameController";
import { EAutoFeedType } from "../../../../Message/Public/EAutoFeedType";
import { MsgManager } from "../../manager/MsgManager";
import { MountConfig } from "../../resource/MountConfig";
import { PulseSharedObject } from "../player/PulseSharedObject";
import { Alert } from "../../../../com/mui/controls/Alert";
import { CheckBoxWin } from "../common/alertwins/CheckBoxWin";
import { GameProxy } from "../../mvc/GameProxy";
import { GameMapUtil } from "../../scene/map/GameMapUtil";
import { MapFileUtil } from "../../scene/map/MapFileUtil";
import { EffectManager } from "../../manager/EffectManager";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
import { GButton } from "../../../../com/mui/controls/GButton";
import { TimeButton } from "../common/button/TimeButton";
type int = number;
//class PackRightPart
    
    export  class PackRightPart extends GSprite
    {
        constructor()
        {
            super();
            return;
        }

        /* internal  */get Hang(): string
        {
            return Language.getString(40076);
        }

        /* internal  */get Back(): string
        {
            return Language.getString(40077);
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            super.createDisposedChildrenImpl();
            this._bg = ObjCreate.createBg(0, 0, 97, 341, this, "PackRightBg");
            this._btnWareHouse = ObjCreate.createGButton(Language.getString(40078), 12, 56, 70, 22, this);
            this._btnShop = ObjCreate.createGButton(Language.getString(40079), 12, 79, 70, 22, this);
            this._btnRepair = UICompomentPool.getUICompoment(RepairAllEquipButton);
            ObjCreate.setObjAttri(this._btnRepair, 12, 102, 70, 22, this);
            this._btnSale = ObjCreate.createGButton(Language.getString(40081), 12, 125, 70, 22, this);
            this._btnHang = ObjCreate.createGButton(Language.getString(40082), 12, 148, 70, 22, this);
            this._btnOpenVIP = ObjCreate.createGButton(Language.getString(40083), 12, 171, 70, 22, this);
            this._btnAutoFeedSet = ObjCreate.createGButton(Language.getString(71354), 12, 194, 70, 22, this);
            if (!this._btnAutoFeed) 
            {
                this._btnAutoFeed = ObjCreate.createTimeButton(Language.getString(71320), 12, 217, 70, 22, this);
                this._btnAutoFeed.name = Language.getString(71320);
            }
            this.addChild(this._btnAutoFeed);
            this._btnWareHouse.configEventListener(flash.events.MouseEvent.CLICK, this.onClickVIPBtn);
            this._btnShop.configEventListener(flash.events.MouseEvent.CLICK, this.onClickVIPBtn);
            this._btnRepair.configEventListener(flash.events.MouseEvent.CLICK, this.onClickVIPBtn);
            this._btnSale.configEventListener(flash.events.MouseEvent.CLICK, this.onClickVIPBtn);
            this._btnHang.configEventListener(flash.events.MouseEvent.CLICK, this.onClickVIPBtn);
            this._btnOpenVIP.configEventListener(flash.events.MouseEvent.CLICK, this.onClickVIPBtn);
            this._btnAutoFeedSet.configEventListener(flash.events.MouseEvent.CLICK, this.onClickVIPBtn);
            this._btnAutoFeed.configEventListener(flash.events.MouseEvent.CLICK, this.onClickVIPBtn);
            this.resetHangText();
            return;
        }

        protected /* override */ disposeImpl(arg1: Boolean=true): void
        {
            this._bg.dispose(arg1);
            this._btnWareHouse.dispose(arg1);
            this._btnShop.dispose(arg1);
            this._btnRepair.dispose(arg1);
            this._btnSale.dispose(arg1);
            this._btnHang.dispose(arg1);
            this._btnOpenVIP.dispose(arg1);
            this._btnAutoFeedSet.dispose(arg1);
            this._bg = null;
            this._btnWareHouse = null;
            this._btnShop = null;
            this._btnRepair = null;
            this._btnSale = null;
            this._btnHang = null;
            this._btnOpenVIP = null;
            this._btnAutoFeedSet = null;
            super.disposeImpl(arg1);
            return;
        }

        public /* override */ dispose(arg1: Boolean=true): void
        {
            disposeChildren(arg1);
            super.dispose(arg1);
            return;
        }

        /* internal  */onClickVIPBtn(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=false;
            var loc2=arg1.currentTarget;
            switch (loc2) 
            {
                case this._btnWareHouse:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.VIPStorageOpen));
                    break;
                }
                case this._btnShop:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.VIPShopOpen));
                    break;
                }
                case this._btnRepair:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ShopFixAllEquipment));
                    break;
                }
                case this._btnSale:
                {
                    if (Cache.instance.shop.operType != ShopOperType.SALE) 
                    {
                        Cache.instance.shop.operType = ShopOperType.SALE;
                    }
                    else 
                    {
                        Cache.instance.shop.operType = "";
                    }
                    break;
                }
                case this._btnHang:
                {
                    if (this._btnHang.label != this.Hang) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.VIPHookQuit));
                    }
                    else 
                    {
                        VIPUtil.toVipHookMap();
                    }
                    break;
                }
                case this._btnOpenVIP:
                {
                    LayerManager.windowLayer.centerWindows(GameController.vip.view, GameController.pack.view);
                    break;
                }
                case this._btnAutoFeedSet:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FeedMemoryModuleShow, 0));
                    break;
                }
                case this._btnAutoFeed:
                {
                    if (Cache.instance.feedMemory.feedType != EAutoFeedType._EFeedTypeMount) 
                    {
                        if (Cache.instance.feedMemory.feedType != EAutoFeedType._EFeedTypeAccumulation) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(71355));
                        }
                        else if (!Cache.instance.role.suitSkillInfo || Cache.instance.role.suitSkillInfo.level <= 0 || Cache.instance.role.suitSkillInfo.skillId == 0) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(69703));
                            return;
                        }
                    }
                    else 
                    {
                        if (!Cache.instance.pack.mountsPackCache.equipEdMount) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(71310));
                            return;
                        }
                        if (MountConfig.instance.isDtModel(Cache.instance.pack.mountsPackCache.equipEdMount.modelId) || Cache.instance.pack.mountsPackCache.isTimeliness(Cache.instance.pack.mountsPackCache.equipEdMount)) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(70264));
                            return;
                        }
                    }
                    loc1 = !PulseSharedObject.isTodayNotTips("PackOnePressFeedAutoFeed");
                    if (loc1) 
                    {
                        Alert.alertWinRenderer = CheckBoxWin;
                        Alert.show(Language.getString(71363), null, Alert.OK | Alert.CANCEL, null, this.onPackOnePressFeedAutoFeed);
                    }
                    else 
                    {
                        GameProxy.autoFeedProxy.feedItem();
                        this._btnAutoFeed.trigger();
                    }
                    break;
                }
            }
            return;
        }

        /* internal  */onPackOnePressFeedAutoFeed(arg1: int, arg2: Boolean): void
        {
            if (arg1 == Alert.OK) 
            {
                Alert.resetToDefault();
                GameProxy.autoFeedProxy.feedItem();
                this._btnAutoFeed.trigger();
            }
            if (arg2) 
            {
                PulseSharedObject.save("PackOnePressFeedAutoFeed", true);
            }
            return;
        }

        /* internal  */onFairylandHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.TreasureWarehourseModuleOpen));
            return;
        }

        public resetHangText(): void
        {
            if (this._btnHang) 
            {
                if (GameMapUtil.isVIPHook(MapFileUtil.mapID)) 
                {
                    this._btnHang.label = this.Back;
                }
                else 
                {
                    this._btnHang.label = this.Hang;
                }
            }
            return;
        }

        public setOpenVIPBlink(arg1: Boolean): void
        {
            if (arg1) 
            {
                EffectManager.glowFilterReg(this._btnOpenVIP, [FilterConst.chatTipsFilter], 0.6, 10, 1);
            }
            else 
            {
                EffectManager.glowFilterUnReg(this._btnOpenVIP);
            }
            return;
        }

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_spContainer: Object /* flash.display.Sprite */;

        /* internal */ /* var */_btnWareHouse: GButton;

        /* internal */ /* var */_btnShop: GButton;

        /* internal */ /* var */_btnRepair: GButton;

        /* internal */ /* var */_btnSale: GButton;

        /* internal */ /* var */_btnHang: GButton;

        /* internal */ /* var */_btnOpenVIP: GButton;

        /* internal */ /* var */_btnAutoFeedSet: GButton;

        /* internal */ /* var */_btnAutoFeed: TimeButton;
    }
